package leetcode.每日一题;

import org.junit.Test;

import java.util.*;

/**
 * @author ：zsy
 * @date ：Created 2021/7/24 10:52
 * @description：https://leetcode-cn.com/problems/latest-time-by-replacing-hidden-digits/
 */
public class 替换隐藏数字得到的最晚时间 {
    @Test
    public void test() {
        Solution solution = new Solution();
        System.out.println(solution.maximumTime("1?:22"));
    }

    class Solution {
        public String maximumTime(String time) {
            char[] chars = time.toCharArray();
            if (chars[0] == '?') {
                chars[0] = ('4' <= chars[1] && chars[1] <= '9') ? '1' : '2';
            }
            if (chars[1] == '?') {
                chars[1] =( chars[0] == '1') ? '9' : '3';
            }
            if (chars[3] == '?') {
                chars[3] = '5';
            }
            if (chars[4] == '?') {
                chars[4] = '9';
            }
            return new String(chars);
        }
    }
}
